

Array.prototype.myReduce3 = function (callback,init = undefined) {
    let start
    //? 累加器 或者叫acc
    let pre
    if (init === undefined) {
        start = 1
        pre = this[0]
    }
    else {
        start = 0
        pre = init
    }
    for (let i = start; i < this.length; i++) {
        pre = callback(pre,this[i],i,this)
    }
    return pre
}


const arr = [1, 2, 3, 10, 22, 6, 7]
console.log(arr.myReduce3((a, b) => a + b))
